home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / HEX8OUT < prev    next >
Encoding:
Text File  |  1985-12-22  |  1.4 KB  |  52 lines

  1. ;-------------------------hex8out routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 53
  4. ;
  5. ; NAME HEX8OUT
  6. ; ROUTINE FOR Conversion from 8-bit Binary to ASCII Hexidecimal
  7. ;
  8. ; FUNCTION: This routine accepts a 8-bit binary number in the DL register
  9. ; and converts it to ASCII hexidecimal form which is sent to the std input
  10. ; device.
  11. ;
  12. ; INPUT: Upon entry an 8-bit binary number is in DL
  13. ; OUTPUT: A string of ASCII digits representing a hexidecimal number is
  14. ; sent out through the std output device.
  15. ; REGISTERS USED:  No registers are modified.  DL is used for input.
  16. ; SEGMENTS REFERENCED:  None
  17. ; ROUTINES CALLED:  STDOUT
  18. ; SPECIAL NOTES: None
  19. ;
  20. ; ROUTINE TO CONVERT FROM INTERNAL 8-BIT BINARY TO ASCII HEXIDECIMAL.
  21. ;
  22. hex8out    proc    far
  23. ;
  24. ; a binary number is in DL
  25. ;
  26.     push    cx        ; save registers
  27.     push    ax
  28. ;
  29.     mov    cx,2        ; loop for a count of two
  30. ;
  31. hex8out1:
  32.     push    cx        ; save the count
  33.     mov    cl,4        ; for a count of four
  34.     rol    dl,cl        ; rotate DL left
  35. ;
  36.     mov    al,dl        ; move into AL
  37.     and    al,00Fh        ; just digit
  38.     daa            ; add 6 if A - F
  39.     add    al,0F0h        ; bump a carry if A - F
  40.     adc    al,040h        ; here is the ASCII
  41.     call    stdout        ; send it
  42. ;
  43.     pop    cx
  44.     loop    hex8out1
  45. ;
  46.     pop    ax        ; restore registers
  47.     pop    cx
  48.     ret            ; return
  49. ;
  50. hex8out    endp
  51. ;-------------------------hex8out routine ends---------------------------+
  52.